package com.example.config;

import com.example.Filter.MyFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.filter.CharacterEncodingFilter;

import javax.servlet.Filter;

@Configuration
public class FilterConfiguration {

    @Bean
    public FilterRegistrationBean filterRegistrationBean(){
        FilterRegistrationBean<Filter> bean = new FilterRegistrationBean<>();
        bean.setFilter(new MyFilter());
        bean.addUrlPatterns("/user/account");
        return bean;
    }

//    @Bean
//    public FilterRegistrationBean FilterRegistrationBean(){
//        FilterRegistrationBean bean = new FilterRegistrationBean();
//        CharacterEncodingFilter encodingFilter = new CharacterEncodingFilter();
//        encodingFilter.setEncoding("GBK");
//        encodingFilter.setForceEncoding(true);
//        bean.setFilter(encodingFilter);
//        bean.addUrlPatterns("/*");
//        return bean;
//    }
}
